﻿using System;

namespace eNets.CBK.Pipe;

partial class StandardPipe<T>
{
    sealed class StandardPipeWriter : IPipeWriter<T>
    {
        public StandardPipeWriter(StandardPipe<T> pipe)
        {
            this.pipe = pipe;
        }

        private StandardPipe<T> pipe;
        
        public Memory<T> GetWritableSequence(int size)
        {
            return this.pipe.buffer.GetWritableSequence(size);
        }

        public void WriterAdvance(int count)
        {
            this.pipe.buffer.WriterAdvance(count);
        }

        public void Flush()
        {
            this.pipe.buffer.Flush();
            this.pipe.WriterFlush();
        }
    }

    
}